﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPageContent.master" AutoEventWireup="false"
    CodeFile="Supplier.aspx.vb" Inherits="Supplier" %>

<%@ Register Src="~/UserControls/DDL.ascx" TagName="DoubleFilteredDropDownList" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/OneFilteredDropDownList.ascx" TagName="OneFilteredDropDownList"
    TagPrefix="uc2" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgSupplier">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgSupplier" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Transparency="20">
    </telerik:RadAjaxLoadingPanel>
    <br />
    <br />
    <telerik:RadGrid ID="rgSupplier" runat="server" GridLines="None" DataSourceID="odsSupplier"
        AllowAutomaticDeletes="True" AllowAutomaticInserts="True" Width="100%" AllowAutomaticUpdates="True"
        AllowPaging="True" AutoGenerateColumns="False" MasterTableView-Dir="<%$ Resources:SystemResource, HTMLDirectionality %>"
        GroupPanel-Text="<%$ Resources:MainGrid ,GroupPanelText %>" CellSpacing="0">
        <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="SupplierID"
            TableLayout="Fixed" DataSourceID="odsSupplier" HorizontalAlign="NotSet" NoMasterRecordsText="<%$ Resources:MainGrid , NoMasterRecordsText %>">
            <CommandItemTemplate>
                <asp:ImageButton ID="ibtnInitInsert" CausesValidation="false" CommandName="InitInsert"
                    runat="server" ImageUrl="~/Design/images/Grid/AddRecord.gif" />
                <asp:LinkButton ID="lbtnInitInsert" CausesValidation="false" runat="server" Font-Size="14px"
                    Text="<%$ Resources:MainGrid , AddNew %>" Visible="true" CommandName="InitInsert" />&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:ImageButton ID="ibtnEditSelected" CausesValidation="false" CommandName="EditSelected"
                    runat="server" ImageUrl="~/Design/images/Grid/Edit.gif" />
                <asp:LinkButton ID="lbtnEditSelected" CausesValidation="false" runat="server" Font-Size="Medium"
                    Text="<%$ Resources:MainGrid , EditSelected %>" Visible="true" CommandName="EditSelected" />&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:ImageButton ID="ibtnDeleteSelected" CausesValidation="false" CommandName="DeleteSelected"
                    OnClientClick="<%$ Resources:MainGrid , OnClientClickDelete %>" runat="server"
                    ImageUrl="~/Design/images/Grid/Delete.gif" />
                <asp:LinkButton ID="lbtnDeleteSelected" Font-Size="Medium" CausesValidation="false"
                    OnClientClick="<%$ Resources:MainGrid , OnClientClickDelete %>" runat="server"
                    Text="<%$ Resources:MainGrid , DeleteSelected %>" CommandName="DeleteSelected" />&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:ImageButton ID="ibtnRebindGrid" CausesValidation="false" CommandName="RebindGrid"
                    runat="server" ImageUrl="~/Design/images/Grid/Refresh.gif" />
                <asp:LinkButton ID="lbtnRebindGrid" Font-Size="Medium" CausesValidation="false" runat="server"
                    Text="<%$ Resources:MainGrid , Refresh %>" CommandName="RebindGrid" />
            </CommandItemTemplate>
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton">
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="SupplierID" HeaderText="ID" ReadOnly="True"
                    SortExpression="SupplierID" UniqueName="SupplierID" >
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SupplierName" meta:ResourceKey="gbcSupplierName"
                    SortExpression="SupplierName" UniqueName="SupplierName">
                    <HeaderStyle Width="200px" />
                    <ItemStyle Width="200px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="BankID" UniqueName="BankID" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridDropDownColumn DataField="BankID" DataSourceID="odsBank" meta:ResourceKey="gbcBank"
                    ListTextField="BankName" ListValueField="BankID"
                    UniqueName="BankName" EnableEmptyListItem="True">
                    <HeaderStyle Width="200px" />
                    <ItemStyle Width="200px" />
                </telerik:GridDropDownColumn>
                <telerik:GridBoundColumn DataField="BankAccountsID" UniqueName="BankAccountsID" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridDropDownColumn DataField="BankAccountsID" DataSourceID="odsAllBankAccounts"
                    meta:ResourceKey="gbcBankAccountsID" ListTextField="AccountNo" ListValueField="ID"
                    UniqueName="BankAccountsID" EnableEmptyListItem="True">
                    <HeaderStyle Width="200px" />
                    <ItemStyle Width="200px" />
                </telerik:GridDropDownColumn>
                <telerik:GridBoundColumn DataField="Mobile" meta:ResourceKey="gbcMobile" SortExpression="Mobile"
                    UniqueName="Mobile">
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Tel" meta:ResourceKey="gbcTel" SortExpression="Tel"
                    UniqueName="Tel">
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn UniqueName="DeleteColumn" ConfirmText="<%$ Resources:MainGrid , ConfirmDelete %>"
                    ConfirmTitle="Confirm" ButtonType="ImageButton" CommandName="Delete">
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings ColumnNumber="2" EditFormType="Template" CaptionDataField="BankID">
                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                    Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Left" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                <FormTemplate>
                    <table id="Table2" cellspacing="2" cellpadding="1" border="0" rules="none">
                        <tr>
                            <td>
                                <asp:Label ID="lblManrtbSupplierName" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                <asp:Label ID="lblSupplierName" runat="server" meta:ResourceKey="lblSupplierName"></asp:Label>
                                &nbsp;&nbsp;
                            </td>
                            <td>
                                <telerik:RadTextBox ID="rtbSupplierName" runat="server" Width="250px" Text='<%# Bind("SupplierName") %>'>
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="rfvrtbSupplierName" runat="server" ControlToValidate="rtbSupplierName"
                                    ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valEditMode"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <asp:Label ID="lblMobile" runat="server" meta:ResourceKey="lblMobile"></asp:Label>
                                
                            </td>
                            <td>
                                <telerik:RadTextBox ID="rtbMobile" Width="250px" runat="server" Text='<%# Bind("Mobile") %>'>
                                </telerik:RadTextBox>
                            </td>
                             <td>
                            </td>
                           
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lblrtbTel" runat="server" meta:ResourceKey="lblTel"></asp:Label>
                                
                            </td>
                            <td>
                                <telerik:RadTextBox ID="rtbTel" Width="250px" runat="server" Text='<%# Bind("Tel") %>'>
                                </telerik:RadTextBox>
                            </td>

                              <td>
                            </td>
                          
                            <td>
                                <asp:Label ID="lblAddress" runat="server" meta:ResourceKey="lblAddress"></asp:Label>
                                
                            </td>
                            <td>
                                <telerik:RadTextBox ID="rtbAddress" Width="250px" runat="server" Text='<%# Bind("Address") %>'>
                                </telerik:RadTextBox>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lblWebAddress" runat="server" meta:ResourceKey="lblWebAddress"></asp:Label>
                              
                            </td>
                            <td>
                                <telerik:RadTextBox ID="rtbWebAddress" Width="250px" runat="server" Text='<%# Bind("WebAddress") %>'>
                                </telerik:RadTextBox>
                            </td>
                            <td>
                            </td>
                            <td>
                                <asp:Label ID="lblEmail" runat="server" meta:ResourceKey="lblEmail"></asp:Label>
                                
                            </td>
                            <td>
                                <telerik:RadTextBox ID="rtbEmail" Width="250px" runat="server" Text='<%# Bind("Email") %>'>
                                </telerik:RadTextBox>
                            </td>
                            <td>
                            </td>
                        </tr>
                      
                            <tr>
                                <td>
                                    <asp:Label ID="lblManWUCBank" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                    <asp:Label ID="lblBank" runat="server" meta:ResourceKey="lblBank"></asp:Label>
                                </td>
                                <td>
                                    <uc2:OneFilteredDropDownList ID="WUCBank" runat="server" DataSourceId="odsBank" DataValueField="BankID"
                                        DefaultChoosedItem="ChooseOne" DataTextField="BankName" AutoPostBack="True"
                                        SelectedValue='<%# Bind("BankID") %>' IsRequired="False" OnSelectedIndexChanged="FillBankAccounts"
                                        CausesValidation="false" />
                                </td>
                                <td></td>
                                <td>
                                    <asp:Label ID="lblMandBankAccountNo" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                    <asp:Label ID="lblBankAccountNo" runat="server" meta:ResourceKey="lblBankAccountNo"></asp:Label>
                                </td>
                                <td>
                                    <uc2:OneFilteredDropDownList ID="WUCBankAccountNo" IsRequired="false" runat="server"
                                        DataSourceId="odsBankAccounts" DataValueField="ID" DefaultChoosedItem="ChooseOne" SelectedValue='<%#  Bind( "BankAccountsID") %>'
                                        DataTextField="AccountNo" />
                                </td>
                                <td></td>
                            
                        </tr>
                        <tr>
                            <td colspan="6">
                                <div style="margin-top: 15px">
                                    <telerik:RadButton ID="btnInsert" meta:ResourceKey="btnInsert" Visible='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "True", "False") %>'
                                        runat="server" CommandName="PerformInsert" Icon-PrimaryIconCssClass="rbOk" ValidationGroup="ValEditMode">
                                    </telerik:RadButton>
                                    <telerik:RadButton ID="btnUpdate" meta:ResourceKey="btnUpdate" Visible='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "False", "True") %>'
                                        runat="server" CommandName="Update" CausesValidation="true" ValidationGroup="ValEditMode"
                                        Icon-PrimaryIconCssClass="rbOk">
                                    </telerik:RadButton>
                                    &nbsp;
                                    <telerik:RadButton ID="btnCancel" meta:ResourceKey="btnCancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel" Icon-PrimaryIconCssClass="rbCancel">
                                    </telerik:RadButton>
                                </div>
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
            <RowIndicatorColumn>
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
            <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                Font-Underline="False" HorizontalAlign="Center" Wrap="True" />
        </MasterTableView>
        <ValidationSettings CommandsToValidate="PerformInsert,Update" ValidationGroup="valEditMode" />
        <ClientSettings AllowDragToGroup="False">
            <Scrolling AllowScroll="false" ScrollHeight="400px" />
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </FilterMenu>
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="odsSupplier" runat="server" DeleteMethod="QueryDatabase"
        InsertMethod="QueryDatabase" SelectMethod="QueryDatabase" TypeName="DBSupplierSP"
        UpdateMethod="QueryDatabase">
        <DeleteParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="DeleteSupplier" Name="Operation" Type="String" />
            <asp:Parameter Name="SupplierID" Type="String" />
            <asp:Parameter Name="SupplierName" Type="String" />
            <asp:Parameter Name="Mobile" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="WebAddress" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="BankID" Type="String" />
            <asp:Parameter Name="BankAccountsID" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="SaveSupplier" Name="Operation" Type="String" />
            <asp:Parameter Name="SupplierID" Type="String" />
            <asp:Parameter Name="SupplierName" Type="String" />
            <asp:Parameter Name="Mobile" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="WebAddress" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="BankID" Type="String" />
            <asp:Parameter Name="BankAccountsID" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvSupplier" Name="Operation" Type="String" />
            <asp:Parameter Name="SupplierID" Type="String" />
            <asp:Parameter Name="SupplierName" Type="String" />
            <asp:Parameter Name="Mobile" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="WebAddress" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="BankID" Type="String" />
            <asp:Parameter Name="BankAccountsID" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="SaveSupplier" Name="Operation" Type="String" />
            <asp:Parameter Name="SupplierID" Type="String" />
            <asp:Parameter Name="SupplierName" Type="String" />
            <asp:Parameter Name="Mobile" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="WebAddress" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="BankID" Type="String" />
            <asp:Parameter Name="BankAccountsID" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsBank" runat="server" SelectMethod="QueryDatabase" TypeName="DBBankSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvBank" Name="Operation" Type="String" />
            <asp:Parameter Name="BankID" Type="String" />
            <asp:Parameter Name="BankName" Type="String" />
            <asp:Parameter Name="BankBranch" Type="String" />
            <asp:Parameter Name="Tel1" Type="String" />
            <asp:Parameter Name="Tel2" Type="String" />
            <asp:Parameter Name="Fax" Type="String" />
            <asp:Parameter Name="WebAddress" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsBankAccounts" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBBankAccountsSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvBankAccountsByBankID" Name="Operation" Type="String" />
            <asp:Parameter Name="ID" Type="String" DefaultValue="" />
            <asp:ControlParameter ControlID="hdnBankID" Name="BankID" PropertyName="Value" Type="String" />
            <asp:Parameter Name="AccountNo" Type="String" />
            <asp:Parameter Name="AccountType" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsAllBankAccounts" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBBankAccountsSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvBankAccounts" Name="Operation" Type="String" />
            <asp:Parameter Name="ID" Type="String" DefaultValue="" />
            <asp:Parameter Name="BankID" Type="String" DefaultValue="" />
            <asp:Parameter Name="AccountNo" Type="String" />
            <asp:Parameter Name="AccountType" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:HiddenField ID="hdnBankID" runat="server" />
</asp:Content>
